home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / oleo-1_4.lha / oleo-1.4 / posixtm.c < prev    next >
C/C++ Source or Header  |  1993-05-21  |  23KB  |  928 lines

  1.  
  2. /*  A Bison parser, made from posixtm.y  */
  3.  
  4. #define YYBISON 1  /* Identify Bison output.  */
  5.  
  6. #define    DIGIT    258
  7.  
  8. #line 19 "posixtm.y"
  9.  
  10. #ifdef __GNUC__
  11. #define alloca __builtin_alloca
  12. #else
  13. #if defined (HAVE_ALLOCA_H) || (defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__))))
  14. #include <alloca.h>
  15. #else
  16. #ifdef _AIX
  17.  #pragma alloca
  18. #else
  19. char *alloca ();
  20. #endif
  21. #endif
  22. #endif
  23.  
  24. #include <stdio.h>
  25. #include <sys/types.h>
  26. #include <time.h>
  27.  
  28. #define YYDEBUG 1
  29.  
  30. /* Lexical analyzer's current scan position in the input string. */
  31. static char *curpos;
  32.  
  33. /* The return value. */
  34. static struct tm t;
  35.  
  36. time_t mktime ();
  37.  
  38. #define psxtparse posixtime_psxtparse
  39. static int psxtlex ();
  40. static int psxterror ();
  41.  
  42. #ifndef YYLTYPE
  43. typedef
  44.   struct psxtltype
  45.     {
  46.       int timestamp;
  47.       int first_line;
  48.       int first_column;
  49.       int last_line;
  50.       int last_column;
  51.       char *text;
  52.    }
  53.   psxtltype;
  54.  
  55. #define YYLTYPE psxtltype
  56. #endif
  57.  
  58. #ifndef YYSTYPE
  59. #define YYSTYPE int
  60. #endif
  61. #include <stdio.h>
  62.  
  63. #ifndef __STDC__
  64. #define const
  65. #endif
  66.  
  67.  
  68.  
  69. #define    YYFINAL        15
  70. #define    YYFLAG        -32768
  71. #define    YYNTBASE    5
  72.  
  73. #define YYTRANSLATE(x) ((unsigned)(x) <= 258 ? psxttranslate[x] : 9)
  74.  
  75. static const char psxttranslate[] = {     0,
  76.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  77.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  78.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  79.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  80.      2,     2,     2,     2,     2,     4,     2,     2,     2,     2,
  81.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  82.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  83.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  84.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  85.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  86.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  87.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  88.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  89.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  90.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  91.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  92.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  93.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  94.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  95.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  96.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  97.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  98.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  99.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  100.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  101.      2,     2,     2,     2,     2,     1,     2,     3
  102. };
  103.  
  104. #if YYDEBUG != 0
  105. static const short psxtprhs[] = {     0,
  106.      0,     7,     9,    12,    13,    14,    17
  107. };
  108.  
  109. #endif
  110.  
  111. static const short psxtrhs[] = {     8,
  112.      8,     8,     8,     6,     7,     0,     8,     0,     8,     8,
  113.      0,     0,     0,     4,     8,     0,     3,     3,     0
  114. };
  115.  
  116. #if YYDEBUG != 0
  117. static const short psxtrline[] = { 0,
  118.     56,    85,    92,    99,   110,   113,   122
  119. };
  120.  
  121. static const char * const psxttname[] = {   "$","error","$illegal.","DIGIT","'.'",
  122. "date","year","seconds","digitpair",""
  123. };
  124. #endif
  125.  
  126. static const short psxtr1[] = {     0,
  127.      5,     6,     6,     6,     7,     7,     8
  128. };
  129.  
  130. static const short psxtr2[] = {     0,
  131.      6,     1,     2,     0,     0,     2,     2
  132. };
  133.  
  134. static const short psxtdefact[] = {     0,
  135.      0,     0,     7,     0,     0,     4,     5,     2,     0,     1,
  136.      3,     6,     0,     0,     0
  137. };
  138.  
  139. static const short psxtdefgoto[] = {    13,
  140.      7,    10,     2
  141. };
  142.  
  143. static const short psxtpact[] = {     2,
  144.      5,     2,-32768,     2,     2,     2,    -3,     2,     2,-32768,
  145. -32768,-32768,     9,    10,-32768
  146. };
  147.  
  148. static const short psxtpgoto[] = {-32768,
  149. -32768,-32768,    -2
  150. };
  151.  
  152.  
  153. #define    YYLAST        10
  154.  
  155.  
  156. static const short psxttable[] = {     4,
  157.      9,     5,     6,     8,     1,    11,    12,     3,    14,    15
  158. };
  159.  
  160. static const short psxtcheck[] = {     2,
  161.      4,     4,     5,     6,     3,     8,     9,     3,     0,     0
  162. };
  163. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  164. #line 3 "/afs/andrew/usr11/lord//lib/bison.simple"
  165.  
  166. /* Skeleton output parser for bison,
  167.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  168.  
  169.    This program is free software; you can redistribute it and/or modify
  170.    it under the terms of the GNU General Public License as published by
  171.    the Free Software Foundation; either version 1, or (at your option)
  172.    any later version.
  173.  
  174.    This program is distributed in the hope that it will be useful,
  175.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  176.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  177.    GNU General Public License for more details.
  178.  
  179.    You should have received a copy of the GNU General Public License
  180.    along with this program; if not, write to the Free Software
  181.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  182.  
  183.  
  184. #ifndef alloca
  185. #ifdef __GNUC__
  186. #define alloca __builtin_alloca
  187. #else /* not GNU C.  */
  188. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc)
  189. #include <alloca.h>
  190. #else /* not sparc */
  191. #if defined (MSDOS) && !defined (__TURBOC__)
  192. #include <malloc.h>
  193. #else /* not MSDOS, or __TURBOC__ */
  194. #if defined(_AIX)
  195. #include <malloc.h>
  196.  #pragma alloca
  197. #endif /* not _AIX */
  198. #endif /* not MSDOS, or __TURBOC__ */
  199. #endif /* not sparc.  */
  200. #endif /* not GNU C.  */
  201. #endif /* alloca not defined.  */
  202.  
  203. /* This is the parser code that is written into each bison parser
  204.   when the %semantic_parser declaration is not specified in the grammar.
  205.   It was written by Richard Stallman by simplifying the hairy parser
  206.   used when %semantic_parser is specified.  */
  207.  
  208. /* Note: there must be only one dollar sign in this file.
  209.    It is replaced by the list of actions, each action
  210.    as one case of the switch.  */
  211.  
  212. #define psxterrok        (psxterrstatus = 0)
  213. #define psxtclearin    (psxtchar = YYEMPTY)
  214. #define YYEMPTY        -2
  215. #define YYEOF        0
  216. #define YYACCEPT    return(0)
  217. #define YYABORT     return(1)
  218. #define YYERROR        goto psxterrlab1
  219. /* Like YYERROR except do call psxterror.
  220.    This remains here temporarily to ease the
  221.    transition to the new meaning of YYERROR, for GCC.
  222.    Once GCC version 2 has supplanted version 1, this can go.  */
  223. #define YYFAIL        goto psxterrlab
  224. #define YYRECOVERING()  (!!psxterrstatus)
  225. #define YYBACKUP(token, value) \
  226. do                                \
  227.   if (psxtchar == YYEMPTY && psxtlen == 1)                \
  228.     { psxtchar = (token), psxtlval = (value);            \
  229.       psxtchar1 = YYTRANSLATE (psxtchar);                \
  230.       YYPOPSTACK;                        \
  231.       goto psxtbackup;                        \
  232.     }                                \
  233.   else                                \
  234.     { psxterror ("syntax error: cannot back up"); YYERROR; }    \
  235. while (0)
  236.  
  237. #define YYTERROR    1
  238. #define YYERRCODE    256
  239.  
  240. #ifndef YYPURE
  241. #define YYLEX        psxtlex()
  242. #endif
  243.  
  244. #ifdef YYPURE
  245. #ifdef YYLSP_NEEDED
  246. #define YYLEX        psxtlex(&psxtlval, &psxtlloc)
  247. #else
  248. #define YYLEX        psxtlex(&psxtlval)
  249. #endif
  250. #endif
  251.  
  252. /* If nonreentrant, generate the variables here */
  253.  
  254. #ifndef YYPURE
  255.  
  256. int    psxtchar;            /*  the lookahead symbol        */
  257. YYSTYPE    psxtlval;            /*  the semantic value of the        */
  258.                 /*  lookahead symbol            */
  259.  
  260. #ifdef YYLSP_NEEDED
  261. YYLTYPE psxtlloc;            /*  location data for the lookahead    */
  262.                 /*  symbol                */
  263. #endif
  264.  
  265. int psxtnerrs;            /*  number of parse errors so far       */
  266. #endif  /* not YYPURE */
  267.  
  268. #if YYDEBUG != 0
  269. int psxtdebug;            /*  nonzero means print parse trace    */
  270. /* Since this is uninitialized, it does not stop multiple parsers
  271.    from coexisting.  */
  272. #endif
  273.  
  274. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  275.  
  276. #ifndef    YYINITDEPTH
  277. #define YYINITDEPTH 200
  278. #endif
  279.  
  280. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  281.     (effective only if the built-in stack extension method is used).  */
  282.  
  283. #if YYMAXDEPTH == 0
  284. #undef YYMAXDEPTH
  285. #endif
  286.  
  287. #ifndef YYMAXDEPTH
  288. #define YYMAXDEPTH 10000
  289. #endif
  290.  
  291. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  292. #define __psxt_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  293. #else                /* not GNU C or C++ */
  294. #ifndef __cplusplus
  295.  
  296. /* This is the most reliable way to avoid incompatibilities
  297.    in available built-in functions on various systems.  */
  298. static void
  299. __psxt_bcopy (from, to, count)
  300.      char *from;
  301.      char *to;
  302.      int count;
  303. {
  304.   register char *f = from;
  305.   register char *t = to;
  306.   register int i = count;
  307.  
  308.   while (i-- > 0)
  309.     *t++ = *f++;
  310. }
  311.  
  312. #else /* __cplusplus */
  313.  
  314. /* This is the most reliable way to avoid incompatibilities
  315.    in available built-in functions on various systems.  */
  316. static void
  317. __psxt_bcopy (char *from, char *to, int count)
  318. {
  319.   register char *f = from;
  320.   register char *t = to;
  321.   register int i = count;
  322.  
  323.   while (i-- > 0)
  324.     *t++ = *f++;
  325. }
  326.  
  327. #endif
  328. #endif
  329.  
  330. #line 169 "/afs/andrew/usr11/lord//lib/bison.simple"
  331. int
  332. psxtparse()
  333. {
  334.   register int psxtstate;
  335.   register int psxtn;
  336.   register short *psxtssp;
  337.   register YYSTYPE *psxtvsp;
  338.   int psxterrstatus;    /*  number of tokens to shift before error messages enabled */
  339.   int psxtchar1;        /*  lookahead token as an internal (translated) token number */
  340.  
  341.   short    psxtssa[YYINITDEPTH];    /*  the state stack            */
  342.   YYSTYPE psxtvsa[YYINITDEPTH];    /*  the semantic value stack        */
  343.  
  344.   short *psxtss = psxtssa;        /*  refer to the stacks thru separate pointers */
  345.   YYSTYPE *psxtvs = psxtvsa;    /*  to allow psxtoverflow to reallocate them elsewhere */
  346.  
  347. #ifdef YYLSP_NEEDED
  348.   YYLTYPE psxtlsa[YYINITDEPTH];    /*  the location stack            */
  349.   YYLTYPE *psxtls = psxtlsa;
  350.   YYLTYPE *psxtlsp;
  351.  
  352. #define YYPOPSTACK   (psxtvsp--, psxtssp--, psxtlsp--)
  353. #else
  354. #define YYPOPSTACK   (psxtvsp--, psxtssp--)
  355. #endif
  356.  
  357.   int psxtstacksize = YYINITDEPTH;
  358.  
  359. #ifdef YYPURE
  360.   int psxtchar;
  361.   YYSTYPE psxtlval;
  362.   int psxtnerrs;
  363. #ifdef YYLSP_NEEDED
  364.   YYLTYPE psxtlloc;
  365. #endif
  366. #endif
  367.  
  368.   YYSTYPE psxtval;        /*  the variable used to return        */
  369.                 /*  semantic values from the action    */
  370.                 /*  routines                */
  371.  
  372.   int psxtlen;
  373.  
  374. #if YYDEBUG != 0
  375.   if (psxtdebug)
  376.     fprintf(stderr, "Starting parse\n");
  377. #endif
  378.  
  379.   psxtstate = 0;
  380.   psxterrstatus = 0;
  381.   psxtnerrs = 0;
  382.   psxtchar = YYEMPTY;        /* Cause a token to be read.  */
  383.  
  384.   /* Initialize stack pointers.
  385.      Waste one element of value and location stack
  386.      so that they stay on the same level as the state stack.
  387.      The wasted elements are never initialized.  */
  388.  
  389.   psxtssp = psxtss - 1;
  390.   psxtvsp = psxtvs;
  391. #ifdef YYLSP_NEEDED
  392.   psxtlsp = psxtls;
  393. #endif
  394.  
  395. /* Push a new state, which is found in  psxtstate  .  */
  396. /* In all cases, when you get here, the value and location stacks
  397.    have just been pushed. so pushing a state here evens the stacks.  */
  398. psxtnewstate:
  399.  
  400.   *++psxtssp = psxtstate;
  401.  
  402.   if (psxtssp >= psxtss + psxtstacksize - 1)
  403.     {
  404.       /* Give user a chance to reallocate the stack */
  405.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  406.       YYSTYPE *psxtvs1 = psxtvs;
  407.       short *psxtss1 = psxtss;
  408. #ifdef YYLSP_NEEDED
  409.       YYLTYPE *psxtls1 = psxtls;
  410. #endif
  411.  
  412.       /* Get the current used size of the three stacks, in elements.  */
  413.       int size = psxtssp - psxtss + 1;
  414.  
  415. #ifdef psxtoverflow
  416.       /* Each stack pointer address is followed by the size of
  417.      the data in use in that stack, in bytes.  */
  418.       psxtoverflow("parser stack overflow",
  419.          &psxtss1, size * sizeof (*psxtssp),
  420.          &psxtvs1, size * sizeof (*psxtvsp),
  421. #ifdef YYLSP_NEEDED
  422.          &psxtls1, size * sizeof (*psxtlsp),
  423. #endif
  424.          &psxtstacksize);
  425.  
  426.       psxtss = psxtss1; psxtvs = psxtvs1;
  427. #ifdef YYLSP_NEEDED
  428.       psxtls = psxtls1;
  429. #endif
  430. #else /* no psxtoverflow */
  431.       /* Extend the stack our own way.  */
  432.       if (psxtstacksize >= YYMAXDEPTH)
  433.     {
  434.       psxterror("parser stack overflow");
  435.       return 2;
  436.     }
  437.       psxtstacksize *= 2;
  438.       if (psxtstacksize > YYMAXDEPTH)
  439.     psxtstacksize = YYMAXDEPTH;
  440.       psxtss = (short *) alloca (psxtstacksize * sizeof (*psxtssp));
  441.       __psxt_bcopy ((char *)psxtss1, (char *)psxtss, size * sizeof (*psxtssp));
  442.       psxtvs = (YYSTYPE *) alloca (psxtstacksize * sizeof (*psxtvsp));
  443.       __psxt_bcopy ((char *)psxtvs1, (char *)psxtvs, size * sizeof (*psxtvsp));
  444. #ifdef YYLSP_NEEDED
  445.       psxtls = (YYLTYPE *) alloca (psxtstacksize * sizeof (*psxtlsp));
  446.       __psxt_bcopy ((char *)psxtls1, (char *)psxtls, size * sizeof (*psxtlsp));
  447. #endif
  448. #endif /* no psxtoverflow */
  449.  
  450.       psxtssp = psxtss + size - 1;
  451.       psxtvsp = psxtvs + size - 1;
  452. #ifdef YYLSP_NEEDED
  453.       psxtlsp = psxtls + size - 1;
  454. #endif
  455.  
  456. #if YYDEBUG != 0
  457.       if (psxtdebug)
  458.     fprintf(stderr, "Stack size increased to %d\n", psxtstacksize);
  459. #endif
  460.  
  461.       if (psxtssp >= psxtss + psxtstacksize - 1)
  462.     YYABORT;
  463.     }
  464.  
  465. #if YYDEBUG != 0
  466.   if (psxtdebug)
  467.     fprintf(stderr, "Entering state %d\n", psxtstate);
  468. #endif
  469.  
  470.   goto psxtbackup;
  471.  psxtbackup:
  472.  
  473. /* Do appropriate processing given the current state.  */
  474. /* Read a lookahead token if we need one and don't already have one.  */
  475. /* psxtresume: */
  476.  
  477.   /* First try to decide what to do without reference to lookahead token.  */
  478.  
  479.   psxtn = psxtpact[psxtstate];
  480.   if (psxtn == YYFLAG)
  481.     goto psxtdefault;
  482.  
  483.   /* Not known => get a lookahead token if don't already have one.  */
  484.  
  485.   /* psxtchar is either YYEMPTY or YYEOF
  486.      or a valid token in external form.  */
  487.  
  488.   if (psxtchar == YYEMPTY)
  489.     {
  490. #if YYDEBUG != 0
  491.       if (psxtdebug)
  492.     fprintf(stderr, "Reading a token: ");
  493. #endif
  494.       psxtchar = YYLEX;
  495.     }
  496.  
  497.   /* Convert token to internal form (in psxtchar1) for indexing tables with */
  498.  
  499.   if (psxtchar <= 0)        /* This means end of input. */
  500.     {
  501.       psxtchar1 = 0;
  502.       psxtchar = YYEOF;        /* Don't call YYLEX any more */
  503.  
  504. #if YYDEBUG != 0
  505.       if (psxtdebug)
  506.     fprintf(stderr, "Now at end of input.\n");
  507. #endif
  508.     }
  509.   else
  510.     {
  511.       psxtchar1 = YYTRANSLATE(psxtchar);
  512.  
  513. #if YYDEBUG != 0
  514.       if (psxtdebug)
  515.     {
  516.       fprintf (stderr, "Next token is %d (%s", psxtchar, psxttname[psxtchar1]);
  517.       /* Give the individual parser a way to print the precise meaning
  518.          of a token, for further debugging info.  */
  519. #ifdef YYPRINT
  520.       YYPRINT (stderr, psxtchar, psxtlval);
  521. #endif
  522.       fprintf (stderr, ")\n");
  523.     }
  524. #endif
  525.     }
  526.  
  527.   psxtn += psxtchar1;
  528.   if (psxtn < 0 || psxtn > YYLAST || psxtcheck[psxtn] != psxtchar1)
  529.     goto psxtdefault;
  530.  
  531.   psxtn = psxttable[psxtn];
  532.  
  533.   /* psxtn is what to do for this token type in this state.
  534.      Negative => reduce, -psxtn is rule number.
  535.      Positive => shift, psxtn is new state.
  536.        New state is final state => don't bother to shift,
  537.        just return success.
  538.      0, or most negative number => error.  */
  539.  
  540.   if (psxtn < 0)
  541.     {
  542.       if (psxtn == YYFLAG)
  543.     goto psxterrlab;
  544.       psxtn = -psxtn;
  545.       goto psxtreduce;
  546.     }
  547.   else if (psxtn == 0)
  548.     goto psxterrlab;
  549.  
  550.   if (psxtn == YYFINAL)
  551.     YYACCEPT;
  552.  
  553.   /* Shift the lookahead token.  */
  554.  
  555. #if YYDEBUG != 0
  556.   if (psxtdebug)
  557.     fprintf(stderr, "Shifting token %d (%s), ", psxtchar, psxttname[psxtchar1]);
  558. #endif
  559.  
  560.   /* Discard the token being shifted unless it is eof.  */
  561.   if (psxtchar != YYEOF)
  562.     psxtchar = YYEMPTY;
  563.  
  564.   *++psxtvsp = psxtlval;
  565. #ifdef YYLSP_NEEDED
  566.   *++psxtlsp = psxtlloc;
  567. #endif
  568.  
  569.   /* count tokens shifted since error; after three, turn off error status.  */
  570.   if (psxterrstatus) psxterrstatus--;
  571.  
  572.   psxtstate = psxtn;
  573.   goto psxtnewstate;
  574.  
  575. /* Do the default action for the current state.  */
  576. psxtdefault:
  577.  
  578.   psxtn = psxtdefact[psxtstate];
  579.   if (psxtn == 0)
  580.     goto psxterrlab;
  581.  
  582. /* Do a reduction.  psxtn is the number of a rule to reduce with.  */
  583. psxtreduce:
  584.   psxtlen = psxtr2[psxtn];
  585.   psxtval = psxtvsp[1-psxtlen]; /* implement default value of the action */
  586.  
  587. #if YYDEBUG != 0
  588.   if (psxtdebug)
  589.     {
  590.       int i;
  591.  
  592.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  593.            psxtn, psxtrline[psxtn]);
  594.  
  595.       /* Print the symbols being reduced, and their result.  */
  596.       for (i = psxtprhs[psxtn]; psxtrhs[i] > 0; i++)
  597.     fprintf (stderr, "%s ", psxttname[psxtrhs[i]]);
  598.       fprintf (stderr, " -> %s\n", psxttname[psxtr1[psxtn]]);
  599.     }
  600. #endif
  601.  
  602.  
  603.   switch (psxtn) {
  604.  
  605. case 1:
  606. #line 62 "posixtm.y"
  607. {
  608.              if (psxtvsp[-5] >= 1 && psxtvsp[-5] <= 12)
  609.            t.tm_mon = psxtvsp[-5] - 1;
  610.          else {
  611.            YYABORT;
  612.          }
  613.          if (psxtvsp[-4] >= 1 && psxtvsp[-4] <= 31)
  614.            t.tm_mday = psxtvsp[-4];
  615.          else {
  616.            YYABORT;
  617.          }
  618.          if (psxtvsp[-3] >= 0 && psxtvsp[-3] <= 23)
  619.            t.tm_hour = psxtvsp[-3];
  620.          else {
  621.            YYABORT;
  622.          }
  623.          if (psxtvsp[-2] >= 0 && psxtvsp[-2] <= 59)
  624.            t.tm_min = psxtvsp[-2];
  625.          else {
  626.            YYABORT;
  627.          }
  628.            ;
  629.     break;}
  630. case 2:
  631. #line 85 "posixtm.y"
  632. {
  633.                    t.tm_year = psxtvsp[0];
  634.            /* Deduce the century based on the year.
  635.               See POSIX.2 section 4.63.3.  */
  636.            if (psxtvsp[0] <= 68)
  637.              t.tm_year += 100;
  638.          ;
  639.     break;}
  640. case 3:
  641. #line 92 "posixtm.y"
  642. {
  643.                             t.tm_year = psxtvsp[-1] * 100 + psxtvsp[0];
  644.                 if (t.tm_year < 1900) {
  645.                   YYABORT;
  646.                 } else
  647.                   t.tm_year -= 1900;
  648.               ;
  649.     break;}
  650. case 4:
  651. #line 99 "posixtm.y"
  652. {
  653.                     time_t now;
  654.             struct tm *tmp;
  655.  
  656.                     /* Use current year.  */
  657.                     time (&now);
  658.             tmp = localtime (&now);
  659.             t.tm_year = tmp->tm_year;
  660.           ;
  661.     break;}
  662. case 5:
  663. #line 110 "posixtm.y"
  664. {
  665.                         t.tm_sec = 0;
  666.               ;
  667.     break;}
  668. case 6:
  669. #line 113 "posixtm.y"
  670. {
  671.                       if (psxtvsp[0] >= 0 && psxtvsp[0] <= 61)
  672.                 t.tm_sec = psxtvsp[0];
  673.               else {
  674.                 YYABORT;
  675.               }
  676.             ;
  677.     break;}
  678. case 7:
  679. #line 122 "posixtm.y"
  680. {
  681.                           psxtval = psxtvsp[-1] * 10 + psxtvsp[0];
  682.             ;
  683.     break;}
  684. }
  685.    /* the action file gets copied in in place of this dollarsign */
  686. #line 442 "/afs/andrew/usr11/lord//lib/bison.simple"
  687.  
  688.   psxtvsp -= psxtlen;
  689.   psxtssp -= psxtlen;
  690. #ifdef YYLSP_NEEDED
  691.   psxtlsp -= psxtlen;
  692. #endif
  693.  
  694. #if YYDEBUG != 0
  695.   if (psxtdebug)
  696.     {
  697.       short *ssp1 = psxtss - 1;
  698.       fprintf (stderr, "state stack now");
  699.       while (ssp1 != psxtssp)
  700.     fprintf (stderr, " %d", *++ssp1);
  701.       fprintf (stderr, "\n");
  702.     }
  703. #endif
  704.  
  705.   *++psxtvsp = psxtval;
  706.  
  707. #ifdef YYLSP_NEEDED
  708.   psxtlsp++;
  709.   if (psxtlen == 0)
  710.     {
  711.       psxtlsp->first_line = psxtlloc.first_line;
  712.       psxtlsp->first_column = psxtlloc.first_column;
  713.       psxtlsp->last_line = (psxtlsp-1)->last_line;
  714.       psxtlsp->last_column = (psxtlsp-1)->last_column;
  715.       psxtlsp->text = 0;
  716.     }
  717.   else
  718.     {
  719.       psxtlsp->last_line = (psxtlsp+psxtlen-1)->last_line;
  720.       psxtlsp->last_column = (psxtlsp+psxtlen-1)->last_column;
  721.     }
  722. #endif
  723.  
  724.   /* Now "shift" the result of the reduction.
  725.      Determine what state that goes to,
  726.      based on the state we popped back to
  727.      and the rule number reduced by.  */
  728.  
  729.   psxtn = psxtr1[psxtn];
  730.  
  731.   psxtstate = psxtpgoto[psxtn - YYNTBASE] + *psxtssp;
  732.   if (psxtstate >= 0 && psxtstate <= YYLAST && psxtcheck[psxtstate] == *psxtssp)
  733.     psxtstate = psxttable[psxtstate];
  734.   else
  735.     psxtstate = psxtdefgoto[psxtn - YYNTBASE];
  736.  
  737.   goto psxtnewstate;
  738.  
  739. psxterrlab:   /* here on detecting error */
  740.  
  741.   if (! psxterrstatus)
  742.     /* If not already recovering from an error, report this error.  */
  743.     {
  744.       ++psxtnerrs;
  745.  
  746. #ifdef YYERROR_VERBOSE
  747.       psxtn = psxtpact[psxtstate];
  748.  
  749.       if (psxtn > YYFLAG && psxtn < YYLAST)
  750.     {
  751.       int size = 0;
  752.       char *msg;
  753.       int x, count;
  754.  
  755.       count = 0;
  756.       for (x = 0; x < (sizeof(psxttname) / sizeof(char *)); x++)
  757.         if (psxtcheck[x + psxtn] == x)
  758.           size += strlen(psxttname[x]) + 15, count++;
  759.       msg = (char *) malloc(size + 15);
  760.       if (msg != 0)
  761.         {
  762.           strcpy(msg, "parse error");
  763.  
  764.           if (count < 5)
  765.         {
  766.           count = 0;
  767.           for (x = 0; x < (sizeof(psxttname) / sizeof(char *)); x++)
  768.             if (psxtcheck[x + psxtn] == x)
  769.               {
  770.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  771.             strcat(msg, psxttname[x]);
  772.             strcat(msg, "'");
  773.             count++;
  774.               }
  775.         }
  776.           psxterror(msg);
  777.           free(msg);
  778.         }
  779.       else
  780.         psxterror ("parse error; also virtual memory exceeded");
  781.     }
  782.       else
  783. #endif /* YYERROR_VERBOSE */
  784.     psxterror("parse error");
  785.     }
  786.  
  787.   goto psxterrlab1;
  788. psxterrlab1:   /* here on error raised explicitly by an action */
  789.  
  790.   if (psxterrstatus == 3)
  791.     {
  792.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  793.  
  794.       /* return failure if at end of input */
  795.       if (psxtchar == YYEOF)
  796.     YYABORT;
  797.  
  798. #if YYDEBUG != 0
  799.       if (psxtdebug)
  800.     fprintf(stderr, "Discarding token %d (%s).\n", psxtchar, psxttname[psxtchar1]);
  801. #endif
  802.  
  803.       psxtchar = YYEMPTY;
  804.     }
  805.  
  806.   /* Else will try to reuse lookahead token
  807.      after shifting the error token.  */
  808.  
  809.   psxterrstatus = 3;        /* Each real token shifted decrements this */
  810.  
  811.   goto psxterrhandle;
  812.  
  813. psxterrdefault:  /* current state does not do anything special for the error token. */
  814.  
  815. #if 0
  816.   /* This is wrong; only states that explicitly want error tokens
  817.      should shift them.  */
  818.   psxtn = psxtdefact[psxtstate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  819.   if (psxtn) goto psxtdefault;
  820. #endif
  821.  
  822. psxterrpop:   /* pop the current state because it cannot handle the error token */
  823.  
  824.   if (psxtssp == psxtss) YYABORT;
  825.   psxtvsp--;
  826.   psxtstate = *--psxtssp;
  827. #ifdef YYLSP_NEEDED
  828.   psxtlsp--;
  829. #endif
  830.  
  831. #if YYDEBUG != 0
  832.   if (psxtdebug)
  833.     {
  834.       short *ssp1 = psxtss - 1;
  835.       fprintf (stderr, "Error: state stack now");
  836.       while (ssp1 != psxtssp)
  837.     fprintf (stderr, " %d", *++ssp1);
  838.       fprintf (stderr, "\n");
  839.     }
  840. #endif
  841.  
  842. psxterrhandle:
  843.  
  844.   psxtn = psxtpact[psxtstate];
  845.   if (psxtn == YYFLAG)
  846.     goto psxterrdefault;
  847.  
  848.   psxtn += YYTERROR;
  849.   if (psxtn < 0 || psxtn > YYLAST || psxtcheck[psxtn] != YYTERROR)
  850.     goto psxterrdefault;
  851.  
  852.   psxtn = psxttable[psxtn];
  853.   if (psxtn < 0)
  854.     {
  855.       if (psxtn == YYFLAG)
  856.     goto psxterrpop;
  857.       psxtn = -psxtn;
  858.       goto psxtreduce;
  859.     }
  860.   else if (psxtn == 0)
  861.     goto psxterrpop;
  862.  
  863.   if (psxtn == YYFINAL)
  864.     YYACCEPT;
  865.  
  866. #if YYDEBUG != 0
  867.   if (psxtdebug)
  868.     fprintf(stderr, "Shifting error token, ");
  869. #endif
  870.  
  871.   *++psxtvsp = psxtlval;
  872. #ifdef YYLSP_NEEDED
  873.   *++psxtlsp = psxtlloc;
  874. #endif
  875.  
  876.   psxtstate = psxtn;
  877.   goto psxtnewstate;
  878. }
  879. #line 126 "posixtm.y"
  880.  
  881. static int
  882. psxtlex ()
  883. {
  884.   char ch = *curpos++;
  885.  
  886.   if (ch >= '0' && ch <= '9')
  887.     {
  888.       psxtlval = ch - '0';
  889.       return DIGIT;
  890.     }
  891.   else if (ch == '.' || ch == 0)
  892.     return ch;
  893.   else
  894.     return '?';            /* Cause an error.  */
  895. }
  896.  
  897. static int
  898. psxterror ()
  899. {
  900.   return 0;
  901. }
  902.  
  903. /* Parse a POSIX-style date and return it, or (time_t)-1 for an error.  */
  904.  
  905. time_t
  906. posixtime (s)
  907.      char *s;
  908. {
  909.   curpos = s;
  910.   /* Let mktime decide whether it is daylight savings time.  */
  911.   t.tm_isdst = -1;
  912.   if (psxtparse ())
  913.     return (time_t)-1;
  914.   else
  915.     return mktime (&t);
  916. }
  917.  
  918. /* Parse a POSIX-style date and return it, or NULL for an error.  */
  919.  
  920. struct tm *
  921. posixtm (s)
  922.      char *s;
  923. {
  924.   if (posixtime (s) == -1)
  925.     return NULL;
  926.   return &t;
  927. }
  928.